package com.itgaoshu.hospitalproject.mapper;

import com.itgaoshu.hospitalproject.bean.*;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;
@Mapper
public interface LadminMapper {
    /**
     * @param register
     * @return
     */
    //住院管理
    //查询未出院患者的所有的信息和根据姓名模糊查询的方法
    List<Register> selRegister(Register register);

    //添加患者信息
    @Insert("insert into register values(null,#{userName},#{age},#{sex},#{departmentId},#{doctorId},#{diagnose},#{address},#{phone},#{idcard},now(),#{bedId},#{operator},#{money},0,#{endDate},#{price},#{discount},#{zhuan})")
    int addRegister(Register register);

    //查询科室信息
    @Select("select * from departments")
    List<Departments> selDepartment();

    //根据科室查询该科室下的医生以及属于住院部的dstate=1
    @Select("select * from doctor where departmentId=#{departmentId} and dstate=1")
    List<Doctor> selDoctor(Integer departmentId);

    //根据科室来查询未被占用的床位的信息
    @Select("select * from bed where departmentId=#{departmentId} and state=#{state}")
    List<Bed> selBed(Bed bed);

    //查询医保折扣的信息
    @Select("select * from moneytype")
    List<Moneytype> selDis();

    //查询待转院的所有患者的信息从门诊传过来的信息
    @Select("select reportid,reportName userName,sex,age,phone,zhuan diagnose,carid idcard from report where state=4")
    List<Register> selDoor();

    //将门诊部门待入院状态改为已入院状态根据reportId
    @Update("update report set state = 5 where reportid=#{reportid}")
    int updateZ(Register register);
    //已入院的时候修改床位的信息，显示已占用该床位
    @Update("update bed set state=1 where bedid=#{bedId}")
    int updateBed(Register register);


    //转科室的方法
    int updateKe(Register register);


}
